import 'package:ccshop/entites/GoodsEntity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'StickyTabBarDelegate.dart';

class HomeMenuListView extends StatefulWidget {
  @override
  _HomeMenuListViewState createState() => _HomeMenuListViewState();
}

class _HomeMenuListViewState extends State<HomeMenuListView>
    with SingleTickerProviderStateMixin {
  List<GoodsEntity> goodsList = List();

  _HomeMenuListViewState() {
    GoodsEntity goodsEntity = GoodsEntity(
      "images/test/test01.png",
      "波兰土豆进口【次日达】",
      "波兰原装进口 新鲜自然 醇香浓厚",
      "￥39.99",
      "￥45.00",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test02.png",
      "瑞士大白菜进口【今日达】",
      "波兰原装进口 清甜可口",
      "￥9.99",
      "￥25.00",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test03.png",
      "粉西红柿（番茄）500g/斤",
      "口味甘甜 圆润可口 皮薄肉多",
      "11.99",
      "￥35.00",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test04.png",
      "新鲜的猪肉 500g/斤",
      "每日新鲜 赶快来买",
      "25.99",
      "￥35.05",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test05.png",
      "刚出的竹笋",
      "大熊猫和人都喜欢吃的",
      "29.99",
      "45.15",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test06.png",
      "超新鲜蒜台 450g/斤",
      "甘甜可口 蒜台炒肉",
      "9.99",
      "18.99",
    );
    goodsList.add(goodsEntity);
  }

  @override
  Widget build(BuildContext context) {
    TabController tabController = TabController(length: 8, vsync: this);
    return NestedScrollView(
        headerSliverBuilder: (context, flag) {
          return [
            SliverPersistentHeader(delegate: StickyTabBarDelegate(
                child: TabBar(
                  tabs: [
                    Tab(text: "猜你喜欢",),
                    Tab(text: "限量特价",),
                    Tab(text: "蔬菜豆制品",),
                    Tab(text: "新鲜水果",),
                    Tab(text: "肉禽蛋",),
                    Tab(text: "海鲜水产",),
                    Tab(text: "熟食凉菜",),
                    Tab(text: "速冻食品",),
                  ],
                )
            ))
          ];
        },
        body: TabBarView(
            controller: tabController,
            children: [
        ])
    );
  }
}
